package com.dingreading.cloud.ssxcx.service.impl;

import com.dingreading.cloud.ssxcx.entity.XcxLessonQuizOptions;
import com.dingreading.cloud.ssxcx.entity.table.XcxLessonQuizOptionsTableDef;
import com.dingreading.cloud.ssxcx.mapper.XcxLessonQuizOptionsMapper;
import com.dingreading.cloud.ssxcx.service.XcxLessonQuizOptionsService;
import com.mybatisflex.core.query.QueryCondition;
import com.mybatisflex.core.query.QueryWrapper;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;

/**
 * 小程序课中题目选项表 服务层实现。
 *
 * @author EDY
 * @since 2025-08-15
 */
@Service
public class XcxLessonQuizOptionsServiceImpl extends BaseServiceImpl<XcxLessonQuizOptionsMapper, XcxLessonQuizOptions, XcxLessonQuizOptionsTableDef> implements XcxLessonQuizOptionsService {

    @Override
    protected XcxLessonQuizOptionsTableDef getTable() {
        return XcxLessonQuizOptionsTableDef.xcxLessonQuizOptions;
    }

    @Override
    public Map<String, Boolean> listByOptionUids(List<String> optionUids) {
        QueryCondition condition = QueryCondition.createEmpty()
                .and(table.uid.in(optionUids))
                .and(table.enabled.eq(1));
        return getMapper().selectListByCondition(condition)
                .stream()
                .collect(Collectors.toMap(XcxLessonQuizOptions::getUid, XcxLessonQuizOptions::getIsCorrect));
    }

}
